using System;
using Machine.Migrations;

public class BaseLine : SimpleMigration
{

	public override void Up()
	{
		AddCustomersTable();
		AddContactsTable();
	}

	private void AddCustomersTable()
	{
		var primaryKey = new Column("Id", ColumnType.Guid, false);
		primaryKey.IsPrimaryKey = true;

		Schema.AddTable("Customers", new[]
		                             {
		                             	primaryKey,
		                             	new Column("CompanyName", ColumnType.NVarChar, 100, false, true),
		                             	new Column("IsActive", ColumnType.Binary, false),
		                             	new Column("Phone", ColumnType.NVarChar, 25, false, true),
		                             	new Column("OriginationDate", ColumnType.DateTime, true),
		                             });

	}

	private void AddContactsTable()
	{
		Column primaryKey;
		primaryKey = new Column("Id", ColumnType.Int32, false);
		primaryKey.IsPrimaryKey = true;
		primaryKey.IsIdentity = true;

		Schema.AddTable("Contacts", new[]
		                            {
		                            	primaryKey,
		                            	new Column("CustomerId", ColumnType.Guid, false),
		                            	new Column("Name", ColumnType.NVarChar, 100, false, true),
		                            });

		Schema.AddForeignKeyConstraint("Contacts", "FK_Contacts_Companies", "CustomerId", "Customers", "Id");

	}

	public override void Down()
	{
		throw new NotImplementedException();
	}
}